﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ParboiledSharp.lang.roboline.ast;

namespace ParboiledSharp.lang.roboline.interpreter
{
    class CommandsStorage
    {
        List<AbstractChunk> commands;
        
        public CommandsStorage() {
            commands = new List<AbstractChunk>(10000);
        }

        public static CommandsStorage FromParserStack(ValueStack stack) {
            int count = stack.Count();
            CommandsStorage storage = new CommandsStorage();
            for (int i = count - 1; i >= 0; i--) {
                AbstractChunk chunk = (AbstractChunk)stack.Peek(i);
                storage.commands.Add(chunk);
            }
            return storage;
        }

        public AbstractChunk this[int index]{
            get { return commands[index]; } 
        }

        public int Count {
            get { return commands.Count;}
        }
    }
}
